package com.jjm.utils;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class MailUtils {

	public static void sendMail(String subject, String msgBody, String emaildestino, String personadestino) {
		
		Properties props = new Properties();
        Session session = Session.getDefaultInstance(props, null);
        try {
            MimeMessage msg = new MimeMessage(session);
            
            msg.setFrom(new InternetAddress("admin@example.com"));
            msg.addRecipient(Message.RecipientType.TO,
                             new InternetAddress(emaildestino, personadestino));
            msg.setSubject(subject);
            msg.setText(msgBody);
            msg.setContent(msgBody, "text/html");
            
            Transport.send(msg);
    
        } catch (Exception e) {
           e.printStackTrace();
        }
	}

}
